#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/3/6 17:39
# @Author  : yingxiao zhang
# @File    : single_ana.py

import pandas as pd

def calculate_max_drawdown(prices):
    # 初始化最大回撤和峰值
    max_drawdown = 0
    peak = prices[0]

    for price in prices:
        # 更新峰值
        if price > peak:
            peak = price
        # 计算当前回撤
        drawdown = (peak - price) / peak
        # 更新最大回撤
        if drawdown > max_drawdown:
            max_drawdown = drawdown

    return max_drawdown

data = pd.read_csv("stocks_data_new/601012.SH.csv")
pd.set_option('display.max_columns', None)

print(data.iloc[0]['trade_date'])
print(data.iloc[0+242]['trade_date'])
print(data.iloc[0+242*3]['trade_date'])
print(data.iloc[0+242*10]['trade_date'])
# data = data.tail(2200)
# print(data.head())
# print(data.tail())
#
#
# close_list = data['close'].tolist()
# # print(close_list[:30])
# # close_list = [float(item.replace(',', '')) for item in close_list]
#
#
# one_rate = (close_list[0] - close_list[250 * 1 - 1])/close_list[250 * 1 - 1]
# three_rate = (close_list[0] - close_list[250 * 3 - 1])/close_list[250 * 3 - 1]
# five_rate = (close_list[0] - close_list[250 * 5 - 1])/close_list[250 * 5 - 1]
# ten_rate = (close_list[0] - close_list[250 * 8 - 1])/close_list[250 * 8 - 1]
# close_list = close_list[:240]
# close_list = close_list[::-1]
# max_drawdown = calculate_max_drawdown(close_list)
# print(one_rate, three_rate, five_rate, ten_rate)
# print(max_drawdown)